package com.example.base.job;

import com.example.base.utils.SpringContextUtils;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

public class AnnotationJob extends QuartzJobBean {

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        JobDetail jobDetail=jobExecutionContext.getJobDetail();
        JobDataMap jobDataMap=jobDetail.getJobDataMap();
        JobModel job =(JobModel) jobDataMap.get("sysjob");
        try {
            if("annotation".equals(job.getType())){
                QuarztUtils quarztUtils= SpringContextUtils.getBean(QuarztUtils.class);
                quarztUtils.executeAnnotationJob(job);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
